﻿<phone:PhoneApplicationPage
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
    xmlns:cal="clr-namespace:Caliburn.Micro;assembly=Caliburn.Micro" 
    xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit" 
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone" x:Class="Wulong.Phone.Qiushi.Views.CommentsView" 
    mc:Ignorable="d" d:DesignWidth="480" d:DesignHeight="480" 
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    >

    <phone:PhoneApplicationPage.Resources>
        <cal:BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" />
        <Style x:Key="LoadingStyle" 
               TargetType="TextBlock" BasedOn="{StaticResource PhoneTextAccentStyle}">
            <Setter Property="FontSize" Value="16" />
            <Setter Property="VerticalAlignment" Value="Bottom" />
            <Setter Property="HorizontalAlignment" Value="Center" />
        </Style>
        <Style x:Key="CommentsListBoxStyle" TargetType="ListBox">
            <Setter Property="Background" Value="Transparent"/>
            <Setter Property="Foreground" Value="{StaticResource PhoneForegroundBrush}"/>
            <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Disabled"/>
            <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto"/>
            <Setter Property="BorderThickness" Value="0"/>
            <Setter Property="BorderBrush" Value="Transparent"/>
            <Setter Property="Padding" Value="0"/>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="ListBox">

                        <ScrollViewer x:Name="ScrollViewer" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" Foreground="{TemplateBinding Foreground}" Padding="{TemplateBinding Padding}">
                            <StackPanel>
                                <ItemsPresenter/>
                            </StackPanel>
                        </ScrollViewer>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
    </phone:PhoneApplicationPage.Resources>

    <!--LayoutRoot is the root grid where all page content is placed-->
    <Grid x:Name="LayoutRoot" Background="Transparent">
        <Grid.RowDefinitions>
            <RowDefinition Height="*"/>
            <RowDefinition Height="Auto"/>
        </Grid.RowDefinitions>


        <ListBox Background="Black" Grid.Row="0" x:Name="Comments" Style="{StaticResource CommentsListBoxStyle}" >
                <ListBox.ItemTemplate>
                    <DataTemplate>
                        <Border Padding="5" Width="440" BorderBrush="Chocolate" >
                            <StackPanel>
                                <StackPanel VerticalAlignment="Top" HorizontalAlignment="Left" Orientation="Horizontal">
                                    <TextBlock Text="{Binding Floor}" Foreground="Gold" Padding="4"/>
                                    <Image Source="{Binding Avatar}" />
                                    <TextBlock Text="{Binding Author}" Foreground="HotPink" FontStyle="Italic" />                   
                                </StackPanel>
                            <TextBlock Text="{Binding Body}" VerticalAlignment="Top" TextWrapping="Wrap" />
                            <toolkit:Separator BorderBrush="PeachPuff" BorderThickness="1" Width="440" />
                        </StackPanel>
                        </Border>
                    </DataTemplate>
                </ListBox.ItemTemplate>
            </ListBox>
        
        <!--TitlePanel contains the name of the application and page title-->
        
        <!--Loading bar and text-->
        <Grid Grid.Row="1"
                      Visibility="{Binding IsBusy, 
                            Converter={StaticResource BooleanToVisibilityConverter}}">
            <Grid.RowDefinitions>
                <RowDefinition />
                <RowDefinition />
            </Grid.RowDefinitions>
            <TextBlock Text="{Binding Path=AppI18N.App_Loading, Source={StaticResource ls}}" 
                               Style="{StaticResource LoadingStyle}"/>
            <toolkit:PerformanceProgressBar IsIndeterminate="{Binding IsBusy}"
                                 VerticalAlignment="Top" 
                                 IsTabStop="True"
                                 Grid.Row="1" />
        </Grid>
    </Grid>

</phone:PhoneApplicationPage>
